const express = require('express')
const multer = require('multer')

const { userController } = require('../controller')
const userValidator = require('../middleware/validator/userValidator')
const { verifyToken } = require('../utils/jwt')

const router = express.Router()

const upload = multer({ dest: 'public/' })

router
	.post('/register', userValidator.register, userController.register)
	.post('/login', userValidator.login, userController.login)
	.get('/list', verifyToken, userController.list)
	.put('/', verifyToken, userValidator.update, userController.update)
	.post(
		'/headimage',
		verifyToken,
		upload.single('headimage'),
		userController.headImage
	)
module.exports = router
